<!DOCTYPE html>
<html>
<head>
    <title>{$user_login} - 个人中心</title>
    <meta name="keywords" content=""/>
    <meta name="description" content="">
    <include file="public@head"/>
    <style>
        .control-label {
            font-weight: bold;
            float: left;
            width: 70px;
        }
    </style>
    <script type="text/html" id="photos-item-tpl">
        <li id="saved-image{id}">
            <input id="photo-{id}" type="hidden" name="photo_urls[]" value="{filepath}">
            <input class="form-control" id="photo-{id}-name" type="text" name="photo_names[]" value="{name}"
                   style="width: 200px;" title="图片名称">
            <img id="photo-{id}-preview" src="{url}" style="height:36px;width: 36px;"
                 onclick="imagePreviewDialog(this.src);">
            <a href="javascript:uploadOneImage('图片上传','#photo-{id}');">替换</a>
            <a href="javascript:(function(){$('#saved-image{id}').remove();})();">移除</a>
        </li>
    </script>
    <script type="text/html" id="files-item-tpl">
        <li id="saved-file{id}">
            <input id="file-{id}" type="hidden" name="file_urls[]" value="{filepath}">
            <input class="form-control" id="file-{id}-name" type="text" name="file_names[]" value="{name}"
                   style="width: 200px;" title="文件名称">
            <a id="file-{id}-preview" href="{preview_url}" target="_blank">下载</a>
            <a href="javascript:uploadOne('文件上传','#file-{id}','file');">替换</a>
            <a href="javascript:(function(){$('#saved-file{id}').remove();})();">移除</a>
        </li>
    </script>
</head>
<body class="body-white" id="top">
    <include file="public@nav" />
    <div class="container tc-main">
        <div class="row">
            <div class="col-md-3">
                <include file="public@usernav" />
            </div>
            <div class="col-md-9">
                <div class="tabs">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#one" data-toggle="tab"><i class="fa fa-home"></i> 上传作品</a></li>
                    </ul>
                    <div class="tab-content">
                        <form action="{:url('Works/addPost')}" method="post" class="form-horizontal js-ajax-form margin-top-20">
                        <div class="tab-pane active" id="one">
                            <br>
                            <form class="js-ajax-form" action="{:url('portal/works/addPost')}" method="post">
                                <div class="form-group">
                                    <label for="contest">赛事</label>
                                    <input type="text" class="form-control" id="contest"  value="{$contest.title|default=''}" disabled />
                                    <input type="hidden" name="post[contest_id]" value="{$contest.id|default=''}">
                                    <input type="hidden" name="post[user_id]" value="{$user.id|default=''}" />
                                    <input type="hidden" name="post[id]" value="{$work.id|default=''}" />
                                </div>
                                <div class="form-group">
                                    <label for="category">赛事分类</label>
                                    <select class="form-control" id="category" name="post[contest_category]">
                                        <option value="0">请选择赛事分类</option>
                                        <if condition="isset($categories)">
                                            <foreach name="categories" item="voo">
                                                <if condition="isset($work.contest_category)">
                                                    <if condition="$work.contest_category eq $voo.category_id">
                                                        <option value="{$voo.category_id}" selected>{$voo.name}</option>
                                                    </if>
                                                    <else/>
                                                    <option value="{$voo.category_id}">{$voo.name}</option>
                                                </if>
                                            </foreach>
                                        </if>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label for="title">作品标题</label>
                                    <input type="text" class="form-control" id="title" placeholder="标题" name="post[title]" value="{$work.title|default=''}">
                                </div>
                                <div class="form-group">
                                    <label for="content">作品描述</label>
                                    <td>
                                        <script type="text/plain" id="content" name="post[description]">
                                            <notempty name="work.description">
                                                {:htmlspecialchars_decode($work.description)}
                                            </notempty>
                                        </script>
                                    </td>
                                </div>
                                <div class="form-group">
                                    <label for="content">相册</label>
                                    <td>
                                        <ul id="photos" class="pic-list list-unstyled form-inline">
                                            <notempty name="work.more.photos">
                                                <foreach name="work.more.photos" item="vo">
                                                    <php>$img_url=cmf_get_image_preview_url($vo['url']);</php>
                                                    <li id="saved-image{$key}">
                                                        <input id="photo-{$key}" type="hidden" name="photo_urls[]"
                                                               value="{$vo.url}">
                                                        <input class="form-control" id="photo-{$key}-name" type="text"
                                                               name="photo_names[]"
                                                               value="{$vo.name|default=''}" style="width: 200px;" title="图片名称">
                                                        <img id="photo-{$key}-preview"
                                                             src="{:cmf_get_image_preview_url($vo['url'])}"
                                                             style="height:36px;width: 36px;"
                                                             onclick="parent.imagePreviewDialog(this.src);">
                                                        <a href="javascript:uploadOneImage('图片上传','#photo-{$key}');">替换</a>
                                                        <a href="javascript:(function(){$('#saved-image{$key}').remove();})();">移除</a>
                                                    </li>
                                                </foreach>
                                            </notempty>
                                        </ul>
                                        <a href="javascript:uploadMultiImage('图片上传','#photos','photos-item-tpl');"
                                           class="btn btn-sm btn-default">选择图片</a>
                                    </td>
                                </div>
                                <div class="form-group">
                                    <label for="content">附件</label>
                                    <td>
                                        <ul id="files" class="pic-list list-unstyled form-inline">
                                            <notempty name="work.more.files">
                                                <foreach name="work.more.files" item="vo">
                                                    <php>$file_url=cmf_get_file_download_url($vo['url']);</php>
                                                    <li id="saved-file{$key}">
                                                        <input id="file-{$key}" type="hidden" name="file_urls[]"
                                                               value="{$vo.url}">
                                                        <input class="form-control" id="file-{$key}-name" type="text"
                                                               name="file_names[]"
                                                               value="{$vo.name}" style="width: 200px;" title="图片名称">
                                                        <a id="file-{$key}-preview" href="{$file_url}" target="_blank">下载</a>
                                                        <a href="javascript:uploadOne('文件上传','#file-{$key}','file');">替换</a>
                                                        <a href="javascript:(function(){$('#saved-file{$key}').remove();})();">移除</a>
                                                    </li>
                                                </foreach>
                                            </notempty>
                                        </ul>
                                        <a href="javascript:uploadMultiFile('附件上传','#files','files-item-tpl','file');"
                                           class="btn btn-sm btn-default">选择文件</a>
                                    </td>
                                </div>
                                <div class="form-group">
                                    <label for="content">音频</label>
                                    <td class="form-inline">
                                        <input id="file-audio" class="form-control" type="text" name="post[more][audio]"
                                               value="{$post.more.audio|default=''}" placeholder="请上传音频文件" style="width: 200px;">
                                        <notempty name="post.more.audio">
                                            <a id="file-audio-preview" href="{:cmf_get_file_download_url($post.more.audio)}"
                                               target="_blank">下载</a>
                                        </notempty>

                                        <a href="javascript:uploadOne('文件上传','#file-audio','audio');">上传</a>
                                    </td>
                                </div>
                                <div class="form-group">
                                    <label for="content">视频</label>
                                    <td class="form-inline">
                                        <input id="file-video" class="form-control" type="text" name="post[more][video]"
                                               value="{$post.more.video|default=''}" placeholder="请上传视频文件" style="width: 200px;">
                                        <notempty name="post.more.video">
                                            <a id="file-video-preview" href="{:cmf_get_file_download_url($post.more.video)}"
                                               target="_blank">下载</a>
                                        </notempty>
                                        <a href="javascript:uploadOne('文件上传','#file-video','video');">上传</a>
                                    </td>
                                </div>
                                <div class="form-group">
                                    <if condition="$update_str eq 0">
                                        <button type="submit" class="btn btn-primary js-ajax-submit">保存</button>
                                        <else/>
                                        <button type="submit" class="btn btn-primary js-ajax-submit" title="报名时间已结束" disabled>提交</button>
                                    </if>
<!--                                    <button type="submit" class="btn btn-primary js-ajax-submit">保存</button>-->
                                </div>
                            </form>
                        </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>

    </div>
    <include file="public@footer" />
    <!-- /container -->
    <include file="public@scripts" />
</body>
<script type="text/javascript" src="__STATIC__/js/admin.js"></script>
<script type="text/javascript">
    //编辑器路径定义
    var editorURL = GV.WEB_ROOT;
</script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript">
    $(function () {

        editorcontent = new baidu.editor.ui.Editor();
        editorcontent.render('content');
        try {
            editorcontent.sync();
        } catch (err) {
        }

        $('.btn-cancel-thumbnail').click(function () {
            $('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
            $('#thumbnail').val('');
        });

    });

</script>
</html>